﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VDS.RDF;
using VDS.RDF.Writing;
using VDS.RDF.Parsing;


namespace Filmi.NonSemantic
{

    public class Kontrol
    {
        public DataContainer getMovieData(String name)
        {
            try
            {
                var nonSemanticController = new NonSemanticController();
                var movieData = nonSemanticController.GetMovieData(name);
                return movieData;
                //do whatever you want with movie data
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                return null;
            }
        }

       
        public IGraph PreberiOwlProfil(String file)
        {
            IGraph g=null;
            try
            {
                 g = new Graph();
                 g.LoadFromFile(file, new TurtleParser());
            }
            catch (RdfParseException parseEx)
            {
                //This indicates a parser error e.g unexpected character, premature end of input, invalid syntax etc.
                Console.WriteLine("Parser Error");
                Console.WriteLine(parseEx.Message);
            }
            catch (RdfException rdfEx)
            {
                //This represents a RDF error e.g. illegal triple for the given syntax, undefined namespace
                Console.WriteLine("RDF Error");
                Console.WriteLine(rdfEx.Message);
            }
            return g;
        }



        public void SaveGraph(IGraph g, String filename)
        {
            RdfXmlWriter writer = new RdfXmlWriter();
            //Set Pretty Print Mode on if supported
            if (writer is IPrettyPrintingWriter)
            {
                ((IPrettyPrintingWriter)writer).PrettyPrintMode = true;
            }

            //Set High Speed Mode forbidden if supported
            if (writer is IHighSpeedWriter)
            {
                ((IHighSpeedWriter)writer).HighSpeedModePermitted = false;
            }

            //Set Compression Level to High if supported
            if (writer is ICompressingWriter)
            {
                ((ICompressingWriter)writer).CompressionLevel = WriterCompressionLevel.High;
            }

            //Save the Graph
            writer.Save(g, filename);
        }

        public void IzpisiRDFModel(IGraph g)
        {
            // Izpišemo model v RDF/XML notaciji na standardni izhod
            RdfXmlWriter rdfxmlwriter = new RdfXmlWriter();
            rdfxmlwriter.Save(g, Console.Out);
        }



    }

}